package bdz.projects.sc.core
{
	
	/**
	 * ...
	 * @author ...
	 */
	public class SCRace 
	{
		public var name:String;
		public var units:SCUnitList;
		public var validUnits:Array;
		public function SCRace(x:XML) {
			
			name = x.@name;
			applyUnits(x.unit);
			
		}
		protected function applyUnits(xlist:XMLList):void {
			units = new SCUnitList(xlist);
			var cnt:Number = 0;
			validUnits = new Array();
			for each(var u:SCUnit in units) {
				if (u.validSelections != null && u.validSelections.length > 0) {
					validUnits[cnt] = u;
				}
				cnt++;
			}
		}
		public function getRandomBuild():SCItemObject {
			var rand:Number = Math.floor(Math.random() * validUnits.length);
			var randUnit:SCUnit = validUnits[rand];
			return randUnit.getRandomItem();
		}
		
	}
	
}